 <?
	require_once("db.php");
	require_once("mail.php");
	require_once("conflict.php");
	extract($_POST);

	$check = 0;	

	$msg = "";
	
	/*switch($category)
	{
		case "Student" : $table = strtolower($category);
			break;
		case "Mentor" : $table = strtolower($category);
			break;
		case "Guide" : $table = strtolower($category);
			break;
		case "College" : $table = strtolower($category);
			break;
		case "Industry" : $table = strtolower($category);
			break;
	}*/

	$date = date("Y-m-d");

	$query = "insert into ".strtolower($type)." (username, email, password, confirm, doc) values ('$txt_username', '$txt_email', '$txt_password', 0, '$date')";
	if($txt_password == $txt_cpassword)
	{
		if(check_uname($txt_username))
		{
			if(check_email($txt_email))
			{
				$result = mysql_query($query);
			}
			else
			{
				$check = 1;
				$msg .= "email already register !!!";
			}
		}
		else
		{
			$check = 1;
			$msg .= "username already exist !!!";
		}
	}
	else
	{
		$check = 1;
		$msg .= "password not matched !!!";
	}


	if($result)
	{
		if(reg_mail($txt_email, $txt_username, $txt_password, $type))
		{
			$msg .= "check your inbox as well as spam folder !!!";
		}
		else
		{
			$msg .= "something wrong with email !!!";
		}
	}
	else if($check != 1)
	{
		$msg .= "something wrong with database !!!";
	}
	//$abcd = mysql_error();
	header("location:../reg/registration.php?msg=$msg");
	//echo $msg;

	
?>
